package com.itheima.stock.controller;

import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.req.LoginReqVo;
import com.itheima.stock.vo.resp.LoginRespVo;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author by itheima
 * @Date 2021/12/29
 * @Description 定义用户访问层
 */
@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/test")
    public String getName(){
        return "itheima";
    }

    /**
     * 登录
     *
     * @param vo 签证官
     * @return {@link R}<{@link LoginRespVo}>
     */
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
        return userService.login(vo);
    }

    /**
     * 获取登录验证码
     *
     * @return {@link R}<{@link Map}>
     */
    @GetMapping("/captcha")
    public R<Map> getCaptcha(){
        return userService.getCaptcha();
    }
}
